<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import paymentMember from '@/api/payment/paymentMember'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  paymentMember.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  paymentMember.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'payment_member',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: paymentMember.getList,
  recycleApi: paymentMember.getRecycleList,
  add: {
    show: true,
    api: paymentMember.save,
    auth: ['payment:member:save']
  },
  edit: {
    show: true,
    api: paymentMember.update,
    auth: ['payment:member:update']
  },
  delete: {
    show: true,
    api: paymentMember.deletes,
    auth: ['payment:member:delete'],
    realApi: paymentMember.realDeletes,
    realAuth: ['payment:member:realDeletes']
  },
  recovery: {
    show: true,
    api: paymentMember.recoverys,
    auth: ['payment:member:recovery']
  },
  import: {
    show: true,
    url: 'payment/member/import',
    templateUrl: 'payment/member/downloadTemplate',
    auth: ['payment:member:import']
  },
  export: {
    show: true,
    url: 'payment/member/export',
    auth: ['payment:member:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "支付方式ID",
    dataIndex: "method_id",
    formType: "input",
    search: true,
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入支付方式ID"
    }
  },
  {
    title: "钻石数量",
    dataIndex: "diamond",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入钻石数量"
    }
  },
  {
    title: "价格(分)",
    dataIndex: "money",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入价格(分)"
    }
  },
  {
    title: "苹果内购产品ID",
    dataIndex: "ios_product_id",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入苹果内购产品ID"
    }
  },
  {
    title: "排序",
    dataIndex: "sort",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入排序"
    }
  },
  {
    title: "首充送充",
    dataIndex: "recharge_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入首充送充"
    }
  },
  {
    title: "是否首充(1是，2否)",
    dataIndex: "is_first",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入是否首充(1是，2否)"
    }
  },
  {
    title: "状态1可用0禁用",
    dataIndex: "status",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入状态1可用0禁用"
    }
  },
  {
    title: "创建人",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "create_time",
    formType: "input",
    search: true,
    addDisplay: false,
    editDisplay: false
  },
  {
    title: "更新时间",
    dataIndex: "update_time",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'payment:member' } </script>